<template>
  <div>
    <el-dialog
      title="成员信息"
      :visible.sync="dialogVisible"
      width="60%"
      :before-close="handleClose"
    >
      <div v-if="data.length > 0" style="display: flex">
        <div
          v-for="(item, index) in data"
          :key="index"
          style="
            display: flex;
            justify-content: center;
            flex-direction: column;
            align-items: center;
            margin: 0 10px 0 0;
          "
        >
          <img src="../../../assets/img/avatur.png" alt="" />
          <div>{{ item.name }}</div>
          <div v-if="item.role == '1'">管理员</div>
          <div v-if="item.role == '0'">普通成员</div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: ["show", "code",'mode'],
  data() {
    return {
      dialogVisible: false,
      data: [],
    };
  },
  methods: {
    handleClose() {
      this.dialogVisible = false;
      this.$emit("close", true);
    },
  },
  watch: {
    show(newV) {
      this.dialogVisible = newV;
    },
    code(newV) {
      if (newV != "") {
        this.$http
          .get("/searchUser", { params: { code: newV, mode: this.mode } })
          .then((res) => {
            if (res.code == 200) {
              this.data = res.data;
            }
          });
      }
    },
  },
};
</script>

<style scoped>
.box {
  justify-content: center;
  flex-direction: column;
  align-items: center;
}
</style>